package com.chen.tankwar;

import java.awt.*;

/**
 * Created by jijie.chen on 2017/11/13.
 */
public class Missile {

    private int x;
    private int y;
    private Direction direction;
    public static final int XSPEED = 30;
    public static final int YSPEED = 30;
    public static final int WIDTH = 10;
    public static final int HEIGHT = 10;


    public  Missile(int x,int y, Direction direction){
        this.x = x;
        this.y = y;
        this.direction = direction;
    }

    public void draw(Graphics g){
        g.setColor(Color.BLACK);
        g.fillOval(x, y, WIDTH, HEIGHT);
        move();
    }


    /**
     * 移动
     */
    private void move() {
        switch (direction) {
            //左
            case LEFT:
                this.x -= XSPEED;
                break;
            //右
            case RIGHT:
                this.x += XSPEED;
                break;
            //上
            case UP:
                this.y -= YSPEED;
                break;
            //下
            case DOWN:
                this.y += YSPEED;
                break;
            //左上
            case LU:
                this.x -= XSPEED;
                this.y -= YSPEED;
                break;
            //左下
            case LD:
                this.x -= XSPEED;
                this.y += YSPEED;
                break;
            //右上
            case RU:
                this.x += XSPEED;
                this.y -= YSPEED;
                break;
            //右下
            case RD:
                this.x += XSPEED;
                this.y += YSPEED;
                break;
            default:
                break;

        }
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Direction getDirection() {
        return direction;
    }

    public void setDirection(Direction direction) {
        this.direction = direction;
    }
}
